package com.yuexun.dhdoctor.module.email.presenter.impl;


import com.yuexun.dhdoctor.module.email.bean.SendBean;
import com.yuexun.dhdoctor.module.email.model.ISendModel;
import com.yuexun.dhdoctor.module.email.presenter.ISendPresenter;
import com.yuexun.dhdoctor.module.email.ui.view.ISendView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by work-jx on 2016/8/1.
 */
public class SendPresenter implements ISendPresenter {
    private ISendView view;
    private ISendModel model;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

    public SendPresenter(ISendModel model, ISendView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void sendMail(Map<String, String> praise) {
        model.sendmail(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<SendBean>() {

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("发送失败");
                    }

                    @Override
                    public void onNext(SendBean s) {
                       view.sendMail(s);
                    }
                });
    }




}
